/**
 * [167] 两数之和 II - 输入有序数组
 *
 * @format
 * @lc app=leetcode.cn id=167 lang=javascript
 */

// @lc code=start
/**
 * @param {number[]} numbers
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function (numbers, target) {
    let [left, right] = [0, numbers.length - 1]
    while (left < right) {
        let sum = numbers[left] + numbers[right]
        if (sum < target) left++
        else if (sum > target) right--
        else break
    }
    return [left + 1, right + 1]
}
// 提交结果
// Accepted
// 23/23 cases passed (60 ms)
// Your runtime beats 78.12 % of javascript submissions
// Your memory usage beats 8.87 % of javascript submissions (50.3 MB)
// @lc code=end
